<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0,user-scalable=no"/>
    <title>Blue's Blog</title>
    <link rel="shortcut icon" th:href="@{/common/image/favicon.ico}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/common/css/main.css}"/>
    <script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>
    <!-- 引入Vue -->
    <script th:src="@{/common/js/vue.min.js}"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" type="text/css" th:href="@{/common/iview/styles/iview.css}"/>
    <!-- 引入组件库 -->
    <script th:src="@{/common/iview/iview.min.js}"></script>
    <style type="text/css">
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body>
<div id="app" v-cloak style="text-align: center;width:200px">
    <i-form ref="formInline" :model="formInline" :rules="ruleInline">
        <Form-item prop="user" >
            <i-input type="text" v-model="formInline.user" placeholder="Username">
            <Icon type="ios-person-outline" slot="prepend"></Icon>
            </i-input>
        </Form-item>
        <Form-item prop="password">
            <i-input type="password" v-model="formInline.password" placeholder="Password">
            <Icon type="ios-locked-outline" slot="prepend"></Icon>
            </i-input>
        </Form-item>
        <Form-item>
            <i-button type="primary" @click="handleSubmit('formInline')">Signin</i-button>
        </Form-item>
    </i-form>
</div>
<script type="text/javascript">
    var mixin = {
        data: function () {
            return {
                formInline: {
                    user: '',
                    password: ''
                },
                ruleInline: {
                    user: [
                        {required: true, message: 'Please fill in the user name', trigger: 'blur'}
                    ],
                    password: [
                        {required: true, message: 'Please fill in the password.', trigger: 'blur'},
                        {type: 'string', min: 1, message: 'The password length cannot be less than 6 bits', trigger: 'blur'}
                    ]
                }
            }
        },
        methods: {
            handleSubmit(name) {
                this.$refs[name].validate(function (valid) {
                    if (valid) {
                        this.$Message.success('Success!');


                    } else {
                        this.$Message.error('Fail!');
                    }
                })
            }
        }
    };
    new Vue({
        el: '#app',
        mixins: typeof mixin != 'undefined' ? [mixin] : {}
    });

</script>
</body>
</html>